package com.ruoyi.hospital.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.hospital.mapper.PrescriptionDetailMapper;
import com.ruoyi.hospital.domain.PrescriptionDetail;
import com.ruoyi.hospital.service.IPrescriptionDetailService;

/**
 * 处方明细Service业务层处理
 *
 * @author qichi
 * @date 2023-07-05
 */
@Service
public class PrescriptionDetailServiceImpl implements IPrescriptionDetailService {
    @Autowired
    private PrescriptionDetailMapper prescriptionDetailMapper;

    /**
     * 查询处方明细
     *
     * @param id 处方明细主键
     * @return 处方明细
     */
    @Override
    public PrescriptionDetail selectPrescriptionDetailById(Long id) {
        return prescriptionDetailMapper.queryById(id);
    }

    /**
     * 查询处方明细列表
     *
     * @param prescriptionDetail 处方明细
     * @return 处方明细
     */
    @Override
    public List<PrescriptionDetail> selectPrescriptionDetailList(PrescriptionDetail prescriptionDetail) {
        return prescriptionDetailMapper.queryAll(prescriptionDetail);
    }

    /**
     * 新增处方明细
     *
     * @param prescriptionDetail 处方明细
     * @return 结果
     */
    @Override
    public int insertPrescriptionDetail(PrescriptionDetail prescriptionDetail) {
        prescriptionDetail.setCreateTime(DateUtils.getNowDate());
        return prescriptionDetailMapper.insert(prescriptionDetail);
    }

    /**
     * 修改处方明细
     *
     * @param prescriptionDetail 处方明细
     * @return 结果
     */
    @Override
    public int updatePrescriptionDetail(PrescriptionDetail prescriptionDetail) {
        prescriptionDetail.setUpdateTime(DateUtils.getNowDate());
        return prescriptionDetailMapper.update(prescriptionDetail);
    }

    /**
     * 批量删除处方明细
     *
     * @param ids 需要删除的处方明细主键
     * @return 结果
     */
    @Override
    public int deletePrescriptionDetailByIds(Long[] ids) {
        return prescriptionDetailMapper.deleteByIds(ids);
    }

    /**
     * 删除处方明细信息
     *
     * @param id 处方明细主键
     * @return 结果
     */
    @Override
    public int deletePrescriptionDetailById(Long id) {
        return prescriptionDetailMapper.deleteById(id);
    }
}
